package com.ruyuan.engine.utils;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

import java.sql.Connection;
import java.sql.DriverManager;

public class ClickHouseUtils {

    static Connection connection;
    static Config config = ConfigFactory.load();

    static {
        try {
            String clickHouseDriver = config.getString(Configuration.CK_JDBC_DRIVER);
            String clickHouseUrl = config.getString(Configuration.CK_JDBC_URL);
            String table = config.getString(Configuration.CK_JDBC_TABLE_NAME);
            Class.forName(clickHouseDriver);
            connection = DriverManager.getConnection(clickHouseUrl);
        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() {
        return connection;
    }
}
